<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <ul>
    <li>001</li>
    <li>002</li>
    <li>003</li>
    <li>004</li>
    <li>005</li>
  </ul>
  <script>
    const lis = document.getElementsByTagName('li');
    // for (let i = 0; i < lis.length; i++) {
    //   lis[i].onclick = function () {
    //     console.log(this.innerHTML);
    //   }
    // }

    const ul1 = document.querySelector('ul');
    ul1.onclick = function (e) {
      if (e.target.tagName === 'LI') {
        console.log(e.target.innerHTML);
      }
      // console.log(e.target.tagName);
    }
    // const ul2 = document.getElementsByTagName('ul')[0];
    // console.log(ul1, ul2);
  </script>
</body>

</html>